#!/bin/sh

sudo apt install -y build-essential cmake mosquitto
git clone https://gitee.com/zcs2631/paho.mqtt.cpp.git
cd paho.mqtt.cpp
git checkout v1.4.1
sed -i 's|github.com/eclipse|gitee.com/zcs2631|g' .gitmodules
git submodule init
git submodule update
cmake -Bbuild -DPAHO_WITH_MQTT_C=ON -DPAHO_BUILD_EXAMPLES=ON .
cmake --build build -j$(nproc)
sudo cmake --build build -t install
cd ..
mosquitto -d
cmake -Bb -DCMAKE_BUILD_TYPE:STRING=Release .
cmake --build b
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
b/mqtt
